package cn.wubo.vrr.help.service.impl;

import cn.wubo.vrr.help.entity.Contract;
import cn.wubo.vrr.help.repository.ContractRepo;
import cn.wubo.vrr.help.service.ContractService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Example;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ContractServiceImpl implements ContractService {
    @Autowired
    ContractRepo contractRepo;

    @Override
    public List<Contract> saveOrUpdateAll(List<Contract> list) {
        if(list.size() > 0){
            Contract query = new Contract();
            query.setEMPLID(list.get(0).getEMPLID());
            contractRepo.deleteAll(contractRepo.findAll(Example.of(query)));
            list = contractRepo.saveAll(list);
        }
        return list;
    }
}
